<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Linkslistsviews extends Model
{
    protected $table = 'links_lists_views';
    protected $primaryKey = 'id';

    public static function getLinksListsViews($links_id,$starttime,$endtime)
    {
        return self::select("pv","miniapp_pv","batch","created_at")->where("links_id",$links_id)->whereBetween("batch",[$starttime,$endtime])->orderBy("id","ASC")->get();
    }

    public static function getLinksListsDetial($links_id,$batch)
    {
        return self::select("id")->where("links_id",$links_id)->where("batch",$batch)->first();
    }

    public static function incrementInfo($id, $key, $value)
    {
        return self::where('id', $id)->increment($key, $value);
    }

    public static function creatLinkslistsviews($links_id,$batch)
    {
        return self::insert(["links_id"=>$links_id,"batch"=>$batch,"pv"=>1,"created_at"=>time()]);
    }

}
